FROM centos:7
MAINTAINER fengyuanfei <fdd39969@163.com>

RUN yum -y groupinstall "Development tools" && \
    yum -y install wget lrzsz vim zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel mysql-devel && \
    cd /usr/src/ && \
    wget https://www.python.org/ftp/python/3.8.8/Python-3.8.8.tar.xz && \
    tar -xvJf  Python-3.8.8.tar.xz && \
    cd Python-3.8.8 && \
    ./configure --enable-optimizations && \
    make && make install && \
    ln -s /usr/local/bin/python3 /usr/bin/python3 && \
    ln -s /usr/local/bin/pip3 /usr/bin/pip3

COPY . /opt
WORKDIR /opt

RUN yum install epel-release -y && \
    yum install nginx -y && \
    mv dashboard.conf /etc/nginx/conf.d/ && \
    #mkdir /opt/devops/uwsgi && \
    #mv uwsgi.ini /opt/devops/uwsgi/ && \
    python3 manage.py migrate && \
    uwsgi --ini /opt/devops/uwsgi/uwsgi.ini && \
    pip3 install uwsgi -i https://mirrors.aliyun.com/pypi/simple && \
    pip3 install daphne -i https://mirrors.aliyun.com/pypi/simple && \
    pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple && \
    ln -n /usr/local/python3/daphane  /usr/local/bin/daphane && \
    systemctl daemon-reload && \
    systemctl start daphane && \
    systemctl enable daphane

EXPOSE 8080 80 

ENTRYPOINT ["nginx"]

#ENTRYPOINT ["python3", "manage.py", "runserver", "0.0.0.0:80"]